using UnityEngine;

namespace Coffee.UIExtensions
{
    // [Assembly-CSharp.dll].Coffee.UIExtensions.EffectPlayer
    [Serializable]
    public class EffectPlayer
    {
        
        #region Coffee.UIExtensions.EffectPlayer.<>c
        // [Assembly-CSharp.dll].Coffee.UIExtensions.EffectPlayer.<>c
        [Serializable]
        private sealed class __c
        {
            // Fields
            public static readonly Coffee.UIExtensions.EffectPlayer.<>c __9;
            public static UnityEngine.Canvas.WillRenderCanvases __9__7_0;
            
            // Methods
            private static __c()
            {
                object val_1 = 536898507;
                val_1 = new System.Object();
                mem2[0] = val_1;
                throw new NullReferenceException();
            }
            public __c()
            {
            
            }
            internal void <OnEnable>b__7_0()
            {
                if((mem[536885659] + 24) < 1)
                {
                        return;
                }
                
                var val_2 = 0;
                do
                {
                    Unknown val_1 = mem[536885659].Item[0];
                    val_2 = val_2 + 1;
                    if((mem[536885659] + 24) == val_2)
                {
                        return;
                }
                
                }
                while(mem[536885659] != 0);
                
                throw new NullReferenceException();
            }
        
        }
        
        #endregion
        
        // Fields
        public bool play;
        public float initialPlayDelay;
        public bool loop;
        public float duration;
        public float loopDelay;
        public UnityEngine.AnimatorUpdateMode updateMode;
        private static System.Collections.Generic.List<System.Action> s_UpdateActions;
        private float _time;
        private System.Action<float> _callback;
        
        // Methods
        public void OnEnable(System.Action<float> callback)
        {
            var val_6;
            var val_7;
            UnityEngine.Canvas.UnityEngine.Canvas.WillRenderCanvases val_8;
            float val_9;
            val_6 = mem[mem[536885659]];
            val_6 = mem[536885659];
            if(val_6 == 0)
            {
                    System.Collections.Generic.List<System.Object> val_1 = 536903657;
                val_1 = new System.Collections.Generic.List<System.Object>();
                mem2[0] = val_1;
                val_7 = 536898507;
                if(mem[536898731] == 0)
            {
                    val_7 = 536898507;
            }
            
                val_8 = mem[mem[536898691] + 8];
                val_8 = mem[536898691] + 8;
                if(val_8 == 0)
            {
                    if(mem[536898731] == 0)
            {
                    val_7 = 536898507;
            }
            
                UnityEngine.Canvas.UnityEngine.Canvas.WillRenderCanvases val_2 = 536897777;
                val_8 = val_2;
                val_2 = new UnityEngine.Canvas.UnityEngine.Canvas.WillRenderCanvases(object:  mem[536898691], method:  1610678747);
                mem2[0] = val_8;
            }
            
                UnityEngine.Canvas.add_willRenderCanvases(value:  val_8);
                val_6 = mem[mem[536885659]];
                val_6 = mem[536885659];
            }
            
            System.Action val_3 = 536881997;
            val_3 = new System.Action(object:  this, method:  1610678739);
            var val_6 = mem[536885659] + 28;
            val_6 = val_6 + 1;
            mem2[0] = val_6;
            if((mem[536885659] + 24) < (mem[536885659] + 16 + 24))
            {
                    var val_5 = (mem[536885659] + 16) + ((mem[536885659] + 24) << 3);
                mem2[0] = (mem[536885659] + 24) + 1;
                mem2[0] = val_3;
            }
            
            if(this.play != false)
            {
                    val_9 = -this.initialPlayDelay;
            }
            else
            {
                    val_9 = 0f;
            }
            
            this._callback = callback;
            mem[1152921504930430440] = val_9;
            throw new NullReferenceException();
        }
        public void OnDisable()
        {
            this._callback = 0;
            System.Action val_1 = 536881997;
            val_1 = new System.Action(object:  this, method:  1610678739);
            bool val_2 = mem[536885659].Remove(item:  val_1);
        }
        public void Play(System.Action<float> callback)
        {
            this._time = 0f;
            this.play = true;
            if(callback == null)
            {
                    return;
            }
            
            this._callback = callback;
        }
        public void Stop()
        {
            this.play = false;
        }
        private void OnWillRenderCanvases()
        {
            float val_4;
            if(this.play == false)
            {
                    return;
            }
            
            if(UnityEngine.Application.isPlaying == false)
            {
                    return;
            }
            
            if(this._callback == null)
            {
                    return;
            }
            
            if(this.updateMode == 2)
            {
                    float val_2 = UnityEngine.Time.unscaledDeltaTime;
            }
            else
            {
                    float val_3 = UnityEngine.Time.deltaTime;
            }
            
            val_3 = this._time + val_3;
            this._time = val_3;
            if(this.duration <= val_3)
            {
                    this.play = this.loop;
                if(this.loop != false)
            {
                    val_4 = -this.loopDelay;
            }
            else
            {
                    val_4 = 0f;
            }
            
                this._time = val_4;
            }
            
            val_3 = val_3 / this.duration;
            goto x2;
        }
        public EffectPlayer()
        {
            this.duration = 1f;
        }
    
    }

}
